package com.gxuwz.medical.tools;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.gxuwz.medical.database.DbUtil;
import com.gxuwz.medical.domain.user.User;

public class LoginDao {
	public  boolean login(String userid,String pwd) throws SQLException{
		Connection con ;
		PreparedStatement stmd = null;
		ResultSet rs = null;

		String sql = "select * from t_user where userid =? and pwd=?";
		con = DbUtil.getConn();
		stmd = con.prepareStatement(sql);
		stmd.setString(1,userid);
		stmd.setString(2, pwd);
		rs = stmd.executeQuery();
		User u = null;
		while(rs.next()){
			u = new User();
	    	u.setUserid(rs.getString(1));
	    	u.setPwd(rs.getString(2));
	    	
	    	return true;
		}
		rs.close();
		stmd.close();
		con.close();
		return false;
		
	}

}
